<template>
  <div>
    <div id="main" style="margin-top: 200px;height: 600px;display: flex"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import {baoList} from "@/api/baobiao/products";
export default {
  name: "index.vue",
  data() {
    return {

    }
  },
  methods: {
    list(){
      baoList().then(r=>{
        console.log(r.data)

        var chartDom = document.getElementById('main');
        var myChart = echarts.init(chartDom);
        var option;

        option = {
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            }
          },
          grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
          },
          xAxis: [
            {
              type: 'category',
              data: r.data.ydata,
              axisTick: {
                alignWithLabel: true
              }
            }
          ],
          yAxis: [
            {
              type: 'value'
            }
          ],
          series: [
            {
              name: 'Direct',
              type: 'bar',
              barWidth: '60%',
              data: r.data.xdata
            }
          ]
        };

        option && myChart.setOption(option);
      })
    }
  },
  created() {
    this.list();
  }
}
</script>

<style scoped>

</style>
